<!DOCTYPE html>
<html>
<head>
    <!-- 页面meta -->
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>用户管理</title>
    <meta name="description" content="描述">
    <meta name="keywords" content="关键字">
    <meta content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no" name="viewport">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="./plugins/elementui/index.css">
    <link rel="stylesheet" href="./plugins/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="./csse/style.css">
    <!-- 引入组件库 -->
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script src="./js/vue.js"></script>
    <script src="./plugins/elementui/index.js"></script>
    <script src="./js/axios-0.18.0.js"></script>
    <!--请求和响应组件-->
    <script src="./js/public.js"></script>
    <style>
        /* 头像相关 */
        .img-avatar {
            display: inline-block !important;
            width: 64px;
            height: 64px;
            line-height: 64px;
            text-align: center;
            vertical-align: middle;
            -webkit-border-radius: 50%;
            border-radius: 50%;
        }

        .img-avatar-48 {
            width: 48px;
            height: 48px;
            line-height: 48px;
        }

        .datatable {
            position: relative;
            box-sizing: border-box;
            -webkit-box-flex: 1;
            width: 100%;
            max-width: 100%;
            font-size: 14px;
            color: rgb(96, 98, 102);
            overflow: hidden;
            flex: 110%;
        }

        .datatable td, .datatable th {
            padding: 12px 0;
            min-width: 0;
            -webkit-box-sizing: border-box;
            box-sizing: border-box;
            text-overflow: ellipsis;
            vertical-align: middle;
            position: relative;
            text-align: left;
        }
    </style>
</head>
<body class="hold-transition">
<div id="app">
    <div class="content-header"></div>

    <div class="app-container">
        <div class="app-container">
            <div class="filter-container" style="width: 55%">
                <span> <font size="2.7px">&nbsp;&nbsp;&nbsp;</font> </span>
                <el-input placeholder="用户名" v-model="pagination.queryString" style="width: 200px;" class="filter-item"
                          @keyup.enter.native="handleFilter"></el-input>
                <el-button @click="findPage(1)" class="dalfBut">查询</el-button>
                <span style="float: right;"><font size="5px" style="font-family: 宋体">圈子信息管理</font></span>
            </div>
        </div>
        <div class="box">
            <el-table size="small" current-row-key="id" :data="dataList" stripe highlight-current-row>
                <el-table-column type="index" align="center" label="序号"></el-table-column>
                <el-table-column prop="uava" label="头像" align="center">
                    <template slot-scope="scope">

                        <img class="img-avatar img-avatar-48 m-r-10" :src="scope.row.uava" width="50" height="50"/>

                    </template>
                </el-table-column>
                <el-table-column prop="uname" label="昵称" align="center" show-overflow-tooltip></el-table-column>
                <el-table-column prop="ugender" label="性别" align="center">
                    <!--       <template slot-scope="scope">
                               <span>{{ scope.row.age == '1' ? '男' : '女'}}</span>
                           </template>-->
                </el-table-column>
                <el-table-column prop="content" label="内容" align="center"></el-table-column>
                <el-table-column prop="privacy" label="隐私" align="center"></el-table-column>
                <el-table-column prop="place" label="地址" align="center"></el-table-column>
                <el-table-column prop="comNum" label="评论" align="center"></el-table-column>
                <el-table-column prop="likeNum" label="喜欢" align="center"></el-table-column>
                <el-table-column prop="pocUrl" label="图片" align="center">
                    <template slot-scope="scope">
                            <img :src="scope.row.pocUrl[0]" width="100" height="100"/>
                    </template>
                </el-table-column>
                <el-table-column prop="pubDate" label="发布时间" align="center">
                    <template slot-scope="scope">
                        <span>{{scope.row.pubDate==null? '':scope.row.pubDate.substring(0,11) }}</span>
                    </template>
                </el-table-column>
                <el-table-column prop="isDel" label="是否删除" align="center">
                           <template slot-scope="scope">
                      <span>{{ scope.row.isDel == '1' ? '是' : '否'}}</span>
                  </template>
                </el-table-column>
                <el-table-column fixed="right" label="操作" width="180" align="center">
                    <template slot-scope="scope">
                        <el-button type="success" icon="el-icon-view" size="mini" @click="circleDeatil(scope.row)"></el-button>
                        <el-button type="primary" size="mini" icon="el-icon-edit" @click="handleUpdate(scope.row)"></el-button>
                        <el-button size="mini" type="danger" icon="el-icon-delete" @click="handleDelete(scope.row)"></el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页-->
            <div class="pagination-container">
                <el-pagination
                        class="pagiantion"
                        @current-change="handleCurrentChange"
                        :current-page="pagination.currentPage"
                        :page-size="pagination.pageSize"
                        layout="total, prev, pager, next, jumper"
                        :total="pagination.total">
                </el-pagination>
            </div>
        </div>
    </div>
</div>
</body>

<script>
    var base = getBackUrl();
    var vue = new Vue({
        el: '#app',
        data: {
            currentDate: new Date(),
            activeName: 'first',//添加/编辑窗口Tab标签名称
            pagination: {//分页相关属性
                currentPage: 1,
                pageSize: 10,
                total: 100,
                queryString: '',
            },
            dataList: [],//列表数据
            formData: {},
            options: [],
            //表单数据
            tableData: [],//新增和编辑表单中对应的健康管理师数据
            dialogFormVisible: false,//控制添加窗口显示/隐藏
            dialogFormVisibleEdit: false,
        },
        created() {
            // check();
            this.findPage();
        },
        methods: {
            circleDeatil(row){
                window.location.href='circleInfo.html?id='+row.id
            },
            //分页查询
            findPage(page) {
             /*   if (page == 1) {//判断是否是从查询按钮那点击进来的,是就重置当前页
                    this.pagination.currentPage = 1;
                }*/
                var param = {
                    currentPage: this.pagination.currentPage,
                    pageSize: this.pagination.pageSize,
                    queryString: this.pagination.queryString
                };
                axios.post(base + "/topic/findPage", param).then((res) => {//发送ajax请求查询会员数据
                    this.dataList = res.data.records;//当前页数据赋值
                    this.pagination.total = res.data.total;//将查询出来的总条数赋值
                });


            },
            // 重置表单
            resetForm() {//重置数据
                this.formData = {};
                this.dynamicInformation = {};
                this.medicalHistory = {};
                this.activeName = 'first';
            },

            // 弹出添加窗口
            handleCreate() {
                this.dialogFormVisible = true;//显示表单
                this.resetForm();//先重置表单数据
                this.findRoleName();
            },
            // 弹出编辑窗口
            handleUpdate(row) {
                this.dialogFormVisibleEdit = true;
                this.resetForm();
                this.findRoleName();
                axios.get(base + "/user/findUserById?id=" + row.id).then((res) => {
                    if (res.data.flag) {//如果查询出来,再显示修改表单,先重置表单,再将查询出来的数据赋值给表单
                        this.formData = res.data.data;
                    } else {
                        this.$message.error(res.data.message);
                        return false;
                    }
                });
            },
            //切换页码
            handleCurrentChange(currentPage) {
                this.pagination.currentPage = currentPage;//先将当前页的页数更新,再调用查询检查组方法
                this.findPage();
            },
            // 删除
            handleDelete(row) {
                this.$confirm('此操作将永久删除该用户信息, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get(base + "/user/setting/deleteUser?id=" + row.id).then((res) => {
                        //判断删除结果
                        if (res.data.flag) {
                            this.$message({
                                type: 'success',
                                message: res.data.message
                            });
                            //重新查询
                            this.findPage();
                        } else {
                            this.$message.error(res.data.message);
                        }
                    });
                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
        }
    })
</script>
</html>
